package com.core.listener;

import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;

import com.core.CoreApplication;
import com.core.activity.ApiConfigValue;
import com.core.util.NiceLogUtil;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;

/**
 * Created by ${nice} on ${2016年04月29日14:09:09}.
 */

public class QQShareListener implements IUiListener {

    @Override
    public void onComplete(Object response) {
        doComplete(response);
    }

    protected void doComplete(Object values) {
        NiceLogUtil.d("doComplete" + " == " + values.toString());
        if(values != null && !values.toString().equals("{}")){
            Intent mIntent = new Intent(ApiConfigValue.ACTION_WX_SHARE);
            mIntent.putExtra(ApiConfigValue.ACTION_KEY, ApiConfigValue.ACTION_VALUE_OK);
            LocalBroadcastManager.getInstance(CoreApplication.getInstance()).sendBroadcast(mIntent);
        }


    }

    @Override
    public void onError(UiError e) {
        NiceLogUtil.d("onError:" + "code:" + e.errorCode + ", msg:"
                + e.errorMessage + ", detail:" + e.errorDetail);

        Intent mIntent = new Intent(ApiConfigValue.ACTION_WX_SHARE);
        mIntent.putExtra(ApiConfigValue.ACTION_KEY, ApiConfigValue.ACTION_VALUE_FAILD);
        LocalBroadcastManager.getInstance(CoreApplication.getInstance()).sendBroadcast(mIntent);
    }

    @Override
    public void onCancel() {
        NiceLogUtil.d("onCancel");

        Intent mIntent = new Intent(ApiConfigValue.ACTION_WX_SHARE);
        mIntent.putExtra(ApiConfigValue.ACTION_KEY, ApiConfigValue.ACTION_VALUE_CANCLE);
        LocalBroadcastManager.getInstance(CoreApplication.getInstance()).sendBroadcast(mIntent);
    }
}
